package com.finir.fakturisanje.domain.beans;

import java.io.Serializable;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cascade;

import com.finir.fakturisanje.domain.Faktura;
import com.finir.fakturisanje.domain.Komitent;
import com.finir.fakturisanje.domain.Preduzece;
import com.finir.fakturisanje.domain.Skladiste;
import com.finir.fakturisanje.domain.StavkaFakture;
import com.finir.fakturisanje.domain.beans.enums.FakturaTip;

/*     */@Entity
/*     */public class FakturaBean
/*     */implements Faktura, Serializable
/*     */{
	/*     */private static final long serialVersionUID = 1L;
	/*     */private Long id;
	/*     */private Skladiste skladiste;
	/*     */private Komitent komitent;
	/*     */private Date datum;
	/*     */private Date valuta;
	/*     */private String otpremnica;
	/*     */private String radniNalog;
	/*     */private String napomena;
	/*     */private Preduzece preduzece;
	/*     */private String ukupnoRecima;
	/*     */private Integer brojFakture;

	private FakturaTip fakturaTip;
	/* 65 */private List<StavkaFakture> stavkeFakture = new ArrayList();

	/*     */
	/*     */public String getUkupnoRecima()
	/*     */{
		/* 48 */return this.ukupnoRecima;
		/*     */}

	/*     */
	/*     */public void setUkupnoRecima(String ukupnoRecima) {
		/* 52 */this.ukupnoRecima = ukupnoRecima;
		/*     */}

	/*     */
	/*     */public Integer getBrojFakture()
	/*     */{
		/* 58 */return this.brojFakture;
		/*     */}

	/*     */
	/*     */public void setBrojFakture(Integer brojFakture) {
		/* 62 */this.brojFakture = brojFakture;
		/*     */}

	/*     */
	/*     */@OneToMany(targetEntity = StavkaFaktureBean.class, cascade = { javax.persistence.CascadeType.ALL }, mappedBy = "faktura")
	/*     */@Cascade( { org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	/*     */public List<StavkaFakture> getStavkeFakture()
	/*     */{
		/* 76 */return this.stavkeFakture;
		/*     */}

	/*     */
	/*     */public void setStavkeFakture(List<StavkaFakture> stavkeFakture)
	/*     */{
		/* 85 */this.stavkeFakture = stavkeFakture;
		/*     */}

	/*     */
	/*     */@ManyToOne(targetEntity = PreduzeceBean.class)
	/*     */public Preduzece getPreduzece()
	/*     */{
		/* 95 */return this.preduzece;
		/*     */}

	/*     */
	/*     */public void setPreduzece(Preduzece preduzece)
	/*     */{
		/* 104 */this.preduzece = preduzece;
		/*     */}

	/*     */
	/*     */@Id
	/*     */@GeneratedValue(strategy = GenerationType.AUTO)
	/*     */public Long getId()
	/*     */{
		/* 115 */return this.id;
		/*     */}

	/*     */
	/*     */public void setId(Long id)
	/*     */{
		/* 124 */this.id = id;
		/*     */}

	/*     */
	/*     */@ManyToOne(targetEntity = SkladisteBean.class)
	/*     */public Skladiste getSkladiste()
	/*     */{
		/* 134 */return this.skladiste;
		/*     */}

	/*     */
	/*     */public void setSkladiste(Skladiste skladiste)
	/*     */{
		/* 143 */this.skladiste = skladiste;
		/*     */}

	/*     */
	/*     */@ManyToOne(targetEntity = KomitentBean.class)
	/*     */public Komitent getKomitent()
	/*     */{
		/* 153 */return this.komitent;
		/*     */}

	/*     */
	/*     */public void setKomitent(Komitent komitent)
	/*     */{
		/* 162 */this.komitent = komitent;
		/*     */}

	/*     */
	/*     */@Temporal(TemporalType.DATE)
	/*     */public Date getDatum()
	/*     */{
		/* 172 */return this.datum;
		/*     */}

	/*     */
	/*     */public void setDatum(Date datum)
	/*     */{
		/* 181 */this.datum = datum;
		/*     */}

	/*     */
	/*     */@Temporal(TemporalType.DATE)
	/*     */public Date getValuta()
	/*     */{
		/* 191 */return this.valuta;
		/*     */}

	/*     */
	/*     */public void setValuta(Date valuta)
	/*     */{
		/* 200 */this.valuta = valuta;
		/*     */}

	/*     */
	/*     */public String getOtpremnica()
	/*     */{
		/* 209 */return this.otpremnica;
		/*     */}

	/*     */
	/*     */public void setOtpremnica(String otpremnica)
	/*     */{
		/* 218 */this.otpremnica = otpremnica;
		/*     */}

	/*     */
	/*     */public String getRadniNalog()
	/*     */{
		/* 227 */return this.radniNalog;
		/*     */}

	/*     */
	/*     */public void setRadniNalog(String radniNalog)
	/*     */{
		/* 236 */this.radniNalog = radniNalog;
		/*     */}

	/*     */
	/*     */public String getNapomena()
	/*     */{
		/* 245 */return this.napomena;
		/*     */}

	/*     */
	/*     */public void setNapomena(String napomena)
	/*     */{
		/* 254 */this.napomena = napomena;
		/*     */}

	/*     */
	/*     */public int hashCode()
	/*     */{
		/* 259 */int hash = 0;
		/* 260 */hash += ((this.id != null) ? this.id.hashCode() : 0);
		/* 261 */return hash;
		/*     */}

	/*     */
	/*     */public boolean equals(Object object)
	/*     */{
		/* 268 */if (!(object instanceof FakturaBean))
			/* 269 */return false;
		/*     */
		/* 271 */FakturaBean other = (FakturaBean) object;
		/*     */
		/* 274 */return ((((this.id != null) || (other.id == null))) && ((
		/* 273 */(this.id == null) || (this.id.equals(other.id)))));
		/*     */}

	/*     */
	/*     */public String toString()
	/*     */{
		/* 282 */DateFormat dFormat = DateFormat.getDateInstance(2);
		/* 283 */return getBrojFakture() + "          "
				+ this.komitent.getNaziv() +
				/* 284 */"         " + dFormat.format(this.datum);
		/*     */}

	/*     */

	public FakturaTip getFakturaTip() {
		return fakturaTip;
	}

	public void setFakturaTip(FakturaTip fakturaTip) {
		this.fakturaTip = fakturaTip;
	}

}
